Git 代理配置
HTTP/HTTPS
1git config --global http.proxy socks://localhost:7890HTTP 和 HTTPS 都使用
http.proxy,不存在名为https.proxy的配置。
配置会写到 ~/.gitconfig 文件中,也可以通过编辑该文件来进行配置。
1[user]
2 email = [email protected]
3 name = planc
4[http]
5 proxy = socks://localhost:7890也可以单独配置指定域名的代理:
1git config --global http.<URL>.proxy socks://localhost:7890注意,HTTP 和 HTTPS 都使用
http.<URL>.proxy,设为https.<URL>.proxy是无效的。
例如:
1git config --global http.http://github.com.proxy socks://localhost:7890 # 代理到 http://github.com
2git config --global http.https://github.com.proxy socks://localhost:7890 # 代理到 https://github.com1[user]
2 email = [email protected]
3 name = planc
4[http "http://github.com"]
5 proxy = socks://localhost:7890
6[http "https://github.com"]
7 proxy = socks://localhost:7890
8SSH
使用 SSH 认证时,只能通过 SSH 的配置文件 ~/.ssh/config 配置代理:
1Host github.com
2 Hostname github.com
3 ServerAliveInterval 55
4 ForwardAgent yes
5 ProxyCommand nc -x localhost:7890 %h %p
nc是一个命令行程序,用来进行转发。也可以使用connect、socat、corkscrew等其他程序,参数的格式也要相应的改变。